package com.panopset.app.panopset;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;

import com.panopset.AbstractApplication;
import com.panopset.Strings;
import com.panopset.gui.FontManager;
import com.panopset.gui.LookAndFeel;
import com.panopset.java.Version;

/**
 *
 * @author Karl Dinwiddie
 */
public class AboutCanvas extends Canvas {

    /**
     * Application title.
     */
    private final String pTitle;

    /**
     * @param title Application title.
     */
    public AboutCanvas(final String title) {
        this.pTitle = title;
    }

    /**
     * 20.
     */
    private static final int Y_TITLE = 20;

    /**
     * 140.
     */
    private static final int X_COPY = 140;

    @Override
    public final void paint(final Graphics g) {
        g.setColor(Color.WHITE);
        g.fillRect(getX(), getY(), getWidth(), getHeight());
        g.setColor(Color.BLACK);
        g.drawRect(getX(), getY(), getWidth() - 1, getHeight() - 1);
        FontMetrics fm = g.getFontMetrics();
        int x = (int) ((getWidth() - fm.stringWidth(pTitle)) / 2);
        g.drawString(pTitle + " " + Version.getVersion(), x, Y_TITLE);
        int b = 255;
        g.setColor(new Color(0x00, 0x00, 0x33));
        g.fillOval(120, 60, 60, 60);
        for (int j = 60; j > 0; j--) {
            if (b > 0) {
                g.setColor(new Color(b < 200 ? b + 30 : b, b, b));
                g.drawOval(120, 60, j, j);
            }
            b = b - 8;
        }
        g.setColor(Color.LIGHT_GRAY);
        g.setFont(FontManager.plainArial());
        fm = g.getFontMetrics();
        final String copy = Strings.COPYRIGHT + " 1996 - 2009 Panopset";
        x = (int) ((getWidth() - fm.stringWidth(copy)) / 2);
        g.drawString(copy, x, X_COPY);
    }



    /**
     * Serial version id.
     */
    private static final long serialVersionUID = Version.UNI_VERSION;
}
